/*
 * @Author: 小豪
 * @Description:
 * @Date: 2024-05-23 10:15:43
 * @LastEditTime: 2024-05-23 10:18:33
 * @FilePath: \bsct\gohub\database\migrations\2024_05_23_101543_add_categories_table.go
 */
package migrations

import (
	"database/sql"
	"gohub/app/models"
	"gohub/pkg/migrate"

	"gorm.io/gorm"
)

func init() {

	type Category struct {
		models.BaseModel

		Name        string `gorm:"type:varchar(255);not null;index"`
		Description string `gorm:"type:varchar(255);default:null"`

		models.CommonTimestampsField
	}

	up := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.AutoMigrate(&Category{})
	}

	down := func(migrator gorm.Migrator, DB *sql.DB) {
		migrator.DropTable(&Category{})
	}

	migrate.Add("2024_05_23_101543_add_categories_table", up, down)
}
